package com.st.warehouse.ui.activity;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.fragment.app.FragmentActivity;

import com.st.warehouse.R;


public abstract class BaseActivity extends FragmentActivity {

    protected LayoutInflater mInflater;
    private ImageView mBack;
    public TextView title;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getContentViewId());
        mInflater = LayoutInflater.from(this);
        initView();
        listener();
    }

    public void initView() {
        // 设置返回图标
        mBack = findViewById(R.id.mBack);
        mBack.setVisibility(View.VISIBLE);
        onBackOnClick();
        // 设置标题
        title = findViewById(R.id.title);
        title.setText(getHeaderTitle());
        //
        ImageView more = findViewById(R.id.more);
        more.setVisibility(View.INVISIBLE);
    }

    public void listener(){

    }

    protected abstract int getContentViewId();

    protected abstract String getHeaderTitle();

    protected void onBackOnClick() {
        mBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }
}
